function [void data]=US_processSlug(time_series,reference,prf,diameter)

ref=mean(reference);
for i=1:size(time_series,2)
    if time_series(i)>ref
        time_series(i)=ref;
    end
end
  
data=medfilt1(time_series,5);
figure
t=1:size(time_series,2);
t=t/prf;
plot(t,data)
xlabel('tempo (s)');ylabel('amostras');

void=data/ref

%% setor circular
diameter=52;
r=diameter/2;
area_t=pi*r^2
for i=1:size(data,2)
    h=data(i)*1000;
    if h<r
        teta=2*acosd((r-h)/r)
        area_sc=area_t*((360-teta)/360)
        x=sqrt(r^2-(r-h)^2);
        area_triang=r*x
        area_vf=area_sc+area_triang;
        vf=area_vf/area_t;
    elseif h==r
        vf=0.5
    elseif h>r
        teta=2*acosd((h-r)/r);
        area_sc=area_t*((360-teta)/360);
        x=sqrt(r^2-(r-h)^2);
        area_triang=r*x;
        area_liq=area_sc+area_triang;    
        area_vf=area_t - area_liq;    
        vf=area_vf/area_t;    
    end
end
vf

